package com.hhd.pdf.component.table;

import com.hhd.pdf.context.GeneratorContext;
import com.itextpdf.text.pdf.PdfPCell;

public class TableBorderHelper {
    private int row = 0;

    private int col = 0;

    public void nextCol() {
        col++;
    }

    public void nextRow() {
        col = 0;
        row++;
    }

    public void setBorder(PdfPCell cell, TableVo tableVo, GeneratorContext context) {
        if (tableVo.hasBorder()) {
            if (row == 0) {
                cell.setBorderWidthTop(1);
            }
            if (col == 0) {
                cell.setBorderWidthLeft(1);
            }
            cell.setBorderWidthRight(1);
            cell.setBorderWidthBottom(1);
            cell.setBorderColor(context.getGeneratorParameters().getBorderColor());
        }
    }

    public void setBorder(PdfPCell cell, GeneratorContext context) {
        if (row == 0) {
            cell.setBorderWidthTop(1);
        }
        if (col == 0) {
            cell.setBorderWidthLeft(1);
        }
        cell.setBorderWidthRight(1);
        cell.setBorderWidthBottom(1);
        cell.setBorderColor(context.getGeneratorParameters().getBorderColor());
    }
}
